Author: Sultan Abdullah
Last Updated: 3/30/2020
Description: Initial investigations on COVID-19 Counties' data so as to discover patterns, spot anomalies, test hypothesis and check assumptions with the help of summary statistics and graphical representations.
Importing Libraries
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
from matplotlib import style
style.use('ggplot')
Reading Data
os.chdir(r"C:\Users\Sultan\Documents\GitHub\covid-19-data-analysis\util\data")
df = pd.read_csv('us-counties.csv')
df.head()
# Let us discribe the dataframe
df.describe()
df.shape
Visulize the Data
# Use only for the first time
# !pip install plotly
# In case you have any issues, run this for only once
# !conda install -c plotly plotly-orca
import plotly.express as px
fig = px.bar(df, x='date', y='cases', color='county', labels={'y':'cases'},
hover_data=['county'],
title='Evolution of Reported COVID-19 Cases in the United States Counties')
fig.write_image('../img/evolution-covid-19-cases-counties.png')
fig.show()
fig = px.bar(df, x='date', y='deaths', color='county', labels={'y':'cases'},
hover_data=['county'],
title='Evolution of Reported COVID-19 Deaths in the United States Counties')
fig.write_image('../img/evolution-covid-19-deaths-counties.png')
fig.show()
# Tree Map Visualization of COVID-19 Death Cases by County and Date
fig = px.treemap(df.sort_values(by='cases', ascending=False).reset_index(drop=True),
path=["county", "date"], values="deaths", height=700,
title='Number of deaths from COVID-19 by County and Date',
color_discrete_sequence = px.colors.qualitative.Prism)
fig.data[0].textinfo = 'label+text+value'
fig.write_image('../img/treemap-of-covid-19-cases-counties.png')
fig.show()
# Tree Map Visualization of COVID-19 Death Cases by County and Date
fig = px.treemap(df.sort_values(by='deaths', ascending=False).reset_index(drop=True),
path=["county", "date"], values="deaths", height=700,
title='Number of deaths from COVID-19 by County and Date',
color_discrete_sequence = px.colors.qualitative.Prism)
fig.data[0].textinfo = 'label+text+value'
fig.write_image('../img/treemap-of-covid-19-deaths-counties.png')
fig.show()